<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <table border="1" id="myTable">
    <tr>
      <th>总额</th>
      <th>水费</th>
      <th>电费</th>
      <th>网费</th>
      <th>余额</th>
    </tr>
  </table>

  <script>
    let salary = prompt('输入余额');
    let water = prompt('输入水费');
    let dian = prompt('输入电费');
    let inter = prompt('输入网费');
    let together = salary - water - dian - inter;

    console.log(salary);
    console.log(water);
    console.log(dian);
    console.log(inter);
    console.log(together);

    let table = document.getElementById('myTable');

    let newRow = document.createElement('tr');

    let salaryCell = document.createElement('td');
    salaryCell.textContent = salary;
    newRow.appendChild(salaryCell);

    let waterCell = document.createElement('td');
    waterCell.textContent = water;
    newRow.appendChild(waterCell);

    let dianCell = document.createElement('td');
    dianCell.textContent = dian;
    newRow.appendChild(dianCell);

    let interCell = document.createElement('td');
    interCell.textContent = inter;
    newRow.appendChild(interCell);

    let togetherCell = document.createElement('td');
    togetherCell.textContent = together;
    newRow.appendChild(togetherCell);

    table.appendChild(newRow);
  </script>
</body>

</html>